$(document).ready(function() {
			$('#example3').dataTable( {
				"bDestroy": true,
				"bProcessing": true,
				"bServerSide": true,
				"sAjaxSource": "ajax_consultaAgendamentos.php",
				"sScrollY": 200,
				"bJQueryUI": true,
				"bLengthChange": false,
				"bPaginate": false,
				/*"sPaginationType": "full_numbers",*/
				"aaSorting": [[ 2, "desc" ],[ 3, "asc" ]],
				"oLanguage": {
					"LengthMenu": "_MENU_ records per page",
					"sUrl": "../../js/datatable_language.txt"
				}/*,
				"aoColumns": [ 
					{ "bSearchable": false,"bVisible":    false },
					{ "bSearchable": false,"bVisible":    false },
					null,
					null,
					null,
					null,
					null
				]*/
			} );
			/* **** FORM DIALOG CADASTRO LAUDO**** */
			

			$( "#dialog-form" ).dialog({
				  autoOpen: false,
				  height: 400,
				  width: 650,
				  modal: true,
				  buttons: {
					"Novo Laudo": function() {
					  var bValid = true;
					},
					Cancel: function() {
					  $(this).dialog( "close" );
					}
				  }
				});
			$('#marcar-todos').click(function(){
				$('table > tbody > tr > td > :checkbox')
				  .attr('checked', $(this).is(':checked'))
				  .trigger('change');
			  });
		} );

function btn_adicionarAgendamento() {
		$("#dialog-form" ).dialog("open");
}

function btn_editarLaudo() {
		window.location.href = "";
}

function btn_acao(pagina, idlaudo, idpaciente,idagendamento) {
	var theForm, idlaudo, idpaciente,idagendamento;
	// Start by creating a <form>
	theForm = document.createElement('form');
	theForm.action = pagina;
	theForm.method = 'POST';
	// Next create the <input>s in the form and give them names and values
	input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'idlaudo';
	input.value = idlaudo;
	
	// Next create the <input>s in the form and give them names and values
	input2 = document.createElement('input');
	input2.type = 'hidden';
	input2.name = 'id';
	input2.value = idpaciente;
	
	// Next create the <input>s in the form and give them names and values
	input3 = document.createElement('input');
	input3.type = 'hidden';
	input3.name = 'idagendamento';
	input3.value = idagendamento;
	
	// Now put everything together...
	theForm.appendChild(input);
	theForm.appendChild(input2);
	theForm.appendChild(input3);
	
	// ...and it to the DOM...
	document.getElementById('hidden_form_container').appendChild(theForm);
	// ...and submit it
	theForm.submit();
}

function btn_acao1(pagina, idlaudo) {
	var theForm, idlaudo;
	// Start by creating a <form>
	theForm = document.createElement('form');
	theForm.action = pagina;
	theForm.method = 'POST';
	// Next create the <input>s in the form and give them names and values
	input = document.createElement('input');
	input.type = 'hidden';
	input.name = 'id';
	input.value = idlaudo;
	
	// Now put everything together...
	theForm.appendChild(input);
	
	// ...and it to the DOM...
	document.getElementById('hidden_form_container').appendChild(theForm);
	// ...and submit it
	theForm.submit();
}

function btn_cancelar(pagina, idlaudo) {
	var dados = "id="+idlaudo;  
	$.ajax({  
		type: "POST",  
		url: pagina,  
		data: dados,  
		success: function( data )  
		{  
			alert(data);
			window.location.href = "consultas.php";
		},
		statusCode: {
			404: function() {
			  alert("Pagina nao encontrada");
			  window.location.href = "consultas.php";
			}
		}
	}); 
}


